Export Data

Customize Exported File Column Headings

Description
This customization shows how to customize the column headings of the exported cvs file. With this customization you can create new titles for the columns in the .csv file that gets created when data is exported using export button.
Variables
Export Button
Select the export button
Table Name
Select a database table
Applies to
P_Export Button class
Code
 
''' 
''' Override the ${Export Button}_Click and customize the 
''' export button functionality
''' Also if the export button is Image button then, second parameter type is ImageClickEventArgs.
''' If the button is of "Button" type then modify the parameter type to EventArgs.
''' 
Public Overrides Sub ${Export Button}_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
    Try
        DbUtils.StartTransaction()
        Dim wc As WhereClause = Me.CreateWhereClause()
        'Create the order by object.
        Dim orderBy As BaseClasses.Data.OrderBy = Nothing
		orderBy = CreateOrderBy()
			  
		' Add each of the columns in order of export.
			   
	    ' Replace "Column1, Column2 and so on" with the actual column names which you want to export to CSV file.
		' For example :
        'Dim columns() as BaseColumn = New BaseColumn() { _
        '     Order_DetailsTable.OrderID, _ 
        '     Order_DetailsTable.ProductID, _ 
        '     Order_DetailsTable.UnitPrice, _ 
        '     Order_DetailsTable.Quantity, _ 
        '     Order_DetailsTable.Discount, _ 
        '     Nothing}
			 
		 Dim columns() as BaseColumn = New BaseColumn() { _
             ${Table Name}Table.Column1, _ 
             ${Table Name}Table.Column2, _ 
             ${Table Name}Table.Column3, _ 
             ${Table Name}Table.Column4, _ 
             ${Table Name}able.Column5, _ 
             Nothing}
		' If you do not want Iron Speed Designer generated column hadings then, list the column headings of your choice here. 
        ' The column headings provided in displayColumn will be displayed in exported CSV file instead of Iron Speed Designer generated columns headings.
        ' Note that even if you are changing one column's heanding, you need to provide all the columns' heanding as a comma separated list. 
                     
        Dim displayColumn as string = "Order Id, Product code, Unit Price, Qunatity, Discount"
		Dim rep as ExportData = New ExportData(${Table Name}Table.Instance, wc, orderBy, columns,displayColumn)
        rep.ExportToCSV(Me.Page.Response)
        Me.Page.CommitTransaction(sender)
          
    Catch ex As Exception
        Me.Page.RollBackTransaction(sender)
        Me.Page.ErrorOnPage = True

        Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
    Finally
        DbUtils.EndTransaction
    End Try

End Sub


     

Terms of Service Privacy Statement